Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Sep 25, 2025

Description

This PR fixes issue #8293 where the condense feature was omitting the initial user message from the summarization process, causing the task context to be lost when resuming after condensation.

Problem

When condensing a conversation:

  • The first user message was preserved in the final result but excluded from what gets summarized
  • This caused the summary to miss the initial ask/context
  • When resuming, the agent would re-answer the original question instead of continuing the work

Solution

Modified the summarizeConversation function to include the first message in the content that gets summarized:

  • Changed from messages.slice(1, -N_MESSAGES_TO_KEEP) to messages.slice(0, -N_MESSAGES_TO_KEEP)
  • The first message is now both included in the summary AND preserved separately as before

Testing

  • Added a new test case that verifies the first message is included in the summarization content
  • All existing tests continue to pass (33 tests total across both test files)
  • The fix maintains backward compatibility with existing behavior

Impact

This ensures that:

  • The initial task context is captured in the summary
  • Resume operations continue from where they left off instead of re-answering the original question
  • Both manual and automatic condense operations preserve full context

Fixes #8293


Important

Fixes issue #8293 by including the first user message in the summarization process to preserve initial task context in summarizeConversation.

  • Behavior:
  • Testing:
    • Adds a test case in condense.spec.ts to verify inclusion of the first message in summarization.
    • All existing tests pass, ensuring backward compatibility.
  • Impact:
    • Preserves full context for resume operations, preventing re-answering of original questions.
    • Supports both manual and automatic condense operations.

This description was created by Ellipsis for c28700e. You can customize this summary. It will automatically update as commits are pushed.

- Modified summarizeConversation to include the first message when creating summary
- Added test to verify first message is included in summarization content
- Fixes issue where initial task context was lost after condensation

Fixes #8293
@roomote roomote bot requested review from cte, jr and mrubens as code owners September 25, 2025 01:44
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Sep 25, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 25, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review initiated: auditing my own code with the impartiality of a mirror judging a mirror.

const firstMessage = messages[0]
// Get messages to summarize, excluding the first message and last N messages
const messagesToSummarize = getMessagesSinceLastSummary(messages.slice(1, -N_MESSAGES_TO_KEEP))
// Get messages to summarize, including the first message but excluding last N messages
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: If N_MESSAGES_TO_KEEP === 0, slice(0, -0) yields an empty array, causing no messages to be summarized. Consider normalizing the end index to undefined when N_MESSAGES_TO_KEEP is 0 (e.g., const end = N_MESSAGES_TO_KEEP ? -N_MESSAGES_TO_KEEP : undefined; const messagesToSummarize = getMessagesSinceLastSummary(messages.slice(0, end));).

import { summarizeConversation, getMessagesSinceLastSummary, N_MESSAGES_TO_KEEP } from "../index"

// Create a mock ApiHandler for testing
class MockApiHandler extends BaseProvider {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This test override uses Anthropic.Messages.MessageParam[], coupling the test to a specific provider SDK. Prefer a provider-agnostic message type to reduce brittleness across providers.

@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Sep 25, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[BUG] Condense omits initial ask; summary loses context, resume re-answers ask

3 participants